package com.example.jpa.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.event.TransactionPhase;
import org.springframework.transaction.event.TransactionalEventListener;

/**
 * @author: qilongxin
 * @date: 2021/12/3 18:17
 */
@Component
@Slf4j
public class EventListener {

    @Async
    @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
    public void onHandler(Integer integer) {
        System.out.println("修改的记录行数" + integer);
        log.info("日志：修改的记录数" +integer);
    }
}
